package lib;

public class Pair<T1, T2>
{
    T1 a;
    T2 b;
    
    public Pair(T1 a, T2 b) 
    {
        this.a = a;
        this.b = b;
    }

    public T1 A() {
        return a;
    }

    public T2 B() {
        return b;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair other = (Pair) obj;
        if (a == null) {
            if (other.a != null)
                return false;
        } else if (!a.equals(other.a))
            return false;
        if (b == null) {
            if (other.b != null)
                return false;
        } else if (!b.equals(other.b))
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((a == null) ? 0 : a.hashCode());
        result = prime * result + ((b == null) ? 0 : b.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return String.format("Pair[%s, %s]", a, b);
    }
}
